home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / MM2_DEV / S / MYUTIL / MISSIMPS.M < prev    next >
Encoding:
Text File  |  1991-04-10  |  2.8 KB  |  125 lines

  1. MODULE MissingIMPs;
  2. (*$E MOS *)
  3.  
  4. (*
  5.  * sieht sich IMP-Dir an und meldet, welche Module davon nicht in
  6.  * der shell resident sind.
  7.  * wird benötigt, um IMP-Ordner auf WORK-Disk für Tiny-Shell zu vervoll-
  8.  * ständigen
  9.  *)
  10.  
  11. FROM SYSTEM IMPORT ADR;
  12. IMPORT GEMDOSIO;
  13.  
  14. FROM InOut IMPORT
  15.   OpenOutput,
  16.   WriteLn, WriteString, ReadString, Write, Read, WriteInt, BusyRead;
  17.  
  18. IMPORT ModBase;
  19.  
  20. FROM Files IMPORT GetStateMsg;
  21.  
  22. FROM Files IMPORT File, Access, Open, Close, Create, State,
  23.         noReplace, GetDateTime, SetDateTime;
  24.  
  25. FROM MOSGlobals IMPORT fFileExists, Date, Time;
  26.  
  27. FROM Binary IMPORT FileSize, WriteBytes, ReadBytes;
  28.  
  29. FROM Directory IMPORT MakeFullPath, DirQuery, DirEntry,
  30.         QueryFiles, QueryAll, subdirAttr, FileAttrSet;
  31.  
  32. FROM Strings IMPORT
  33.   Space, Length, String, Concat, Empty;
  34.  
  35.  
  36. PROCEDURE error (res: INTEGER);
  37.   VAR s: String;
  38.   BEGIN
  39.     GetStateMsg (res, s);
  40.     WriteString (s);
  41.   END error;
  42.  
  43. VAR destPath: String;
  44. buf: ARRAY [1..$8000] OF CARDINAL;
  45.  
  46. PROCEDURE delEntry (REF path: ARRAY OF CHAR; e: DirEntry): BOOLEAN;
  47.  
  48.   VAR res: INTEGER; p,p2: String; ok: BOOLEAN; ch: CHAR;
  49.         resident: BOOLEAN;
  50.         mname: String; ref: ModBase.ModRef;
  51.         n: LONGCARD;
  52.         dat2: Date; tim2: Time; fOld, fNew: File;
  53.   
  54.   BEGIN
  55.     Concat (path, e.name, p, ok);
  56.     Concat (destPath, e.name, p2, ok);
  57.     WriteLn;
  58.     WriteString (e.name);
  59.     resident:= FALSE;
  60.     IF ModBase.ModLoaded (e.name, FALSE, mname, ref) THEN
  61.       IF ModBase.linked IN ref^.state THEN
  62.         resident:= TRUE
  63.       END
  64.     END;
  65.     IF resident THEN
  66.     ELSE
  67.       
  68.       Open (fOld, p, readOnly);
  69.       GetDateTime (fOld, dat2, tim2);
  70.       IF State (fOld) < 0 THEN
  71.         HALT
  72.       END;
  73.       Create (fNew, p2, writeOnly, noReplace);
  74.       IF State (fNew) = fFileExists THEN
  75.         WriteString (' exists');
  76.       ELSIF State (fNew) < 0 THEN
  77.         HALT
  78.       ELSE
  79.         LOOP
  80.           ReadBytes (fOld, ADR (buf), SIZE (buf), n);
  81.           IF n=0L THEN EXIT END;
  82.           WriteBytes (fNew, ADR (buf), n)
  83.         END;
  84.         Close (fNew);
  85.         Open (fNew, p2, writeOnly);
  86.         SetDateTime (fNew, dat2, tim2);
  87.         Close (fNew);
  88.       END;
  89.       Close (fOld);
  90.       
  91.     END;
  92.     RETURN TRUE
  93.   END delEntry;
  94.  
  95. VAR s: String;
  96.     ch: CHAR;
  97.     res: INTEGER;
  98.  
  99. BEGIN
  100.   (*
  101.   OpenOutput ('TXT');
  102.   *)
  103.   LOOP
  104.     (*
  105.     WriteString ('Dateien? ');
  106.     ReadString (s);
  107.     *)
  108.     s:= 'j:\linker\sys\imp\*.imp';
  109.     IF Empty (s) THEN EXIT END;
  110.     (*
  111.     WriteString ('Dest-Path? ');
  112.     ReadString (destPath);
  113.     *)
  114.     destPath:= 'f:\tmp\imp\';
  115.     DirQuery (s, FileAttrSet {}, delEntry, res);
  116.     WriteLn;
  117.     IF res < 0 THEN
  118.       error (res);
  119.       WriteLn
  120.     END;
  121.     WriteLn;
  122.     EXIT
  123.   END
  124. END MissingIMPs.
  125.